home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-28 | 65.0 KB | 2,418 lines | [TEXT/MPS ] |
- /*
- File: WinStat.cpp
-
- Contains: Definition of ODWindowState class
-
- Owned by: Chris Linn
-
- Copyright: © 1994 - 1996 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <4> 7/31/96 CSL 1373366: Problem with hidden floating
- windows
- <3> 6/21/96 CSL 1315410: Windows won't select properly.
- 1331320: New windows shown hilited when
- opened with process in background.
- <2> 1/15/96 TJ Cleaned Up
- <82> 11/2/95 RR #1298525, 1298642 Internalize now uses a
- SUView on the draftsProperties, and checks
- for reference validity
- <81> 10/26/95 eeh 1296308: deal with non-persistant frames in
- Internalize
- <80> 10/24/95 RR #1295596 OpenWindows no longer calls
- select() during normal document open.
- <79> 10/18/95 RR 1289153: Recover from exceptions creating /
- internalizing / registering
- windows. Added TRY/CATCH in CATCH block of
- ::INnternalize
- <78> 10/17/95 jpa 1289153: Recover from exceptions creating /
- internalizing / registering windows.
- <77> 10/16/95 RR #1293067 Pass shouldDispose to
- RegisterWindow
- <76> 10/8/95 TJ Fixes Recomended by Refball
- <75> 10/3/95 eeh 1287095: use ReleaseObject in
- RegisterWindow
- <74> 10/3/95 TJ Changes done by RefBall Team
- <73> 9/21/95 RR # 1285189 AcquireFrontWindow calls
- FrontWindow() rather than
- GetFrontNonFloatingWindow
- <72> 9/13/95 TÇ 1282067 FB3: UI temp var before SOM_TRY
- <71> 9/12/95 RR #1274439 Don't activate/deactivate windows
- when in background
- <70> 9/6/95 RR #(1236387) Deactivate before suspend.
- Reactivate after Resume
- <69> 9/1/95 RR # 1279100/1280338 Added IsActive test to
- SelectODWindow
- <68> 8/26/95 TÇ 1274606 FB2: Patching Remarks
- <67> 8/25/95 JBS 1263078 FB: fix part editor swapping
- <66> 8/15/95 RR # 1233767 Use window iterator in
- SuspendResume
- <65> 8/12/95 TÇ 1276812 Need to use TempObjs and TempRefs
- for exception safety and to avoid TRY
- blocks, 1276807 Opt./Bug: use StdTypIO
- routines for portable streaming & smaller
- footprint, 1276806 Optimization: use
- kODFalse instead of kODTrue in comparisons
- <64> 8/3/95 RR #1257260: Collapse B classes. Remove
- somInit methods. Don't call IsInitialized
- or SubclassResponsibility
- <63> 8/2/95 VL 1270320: Correct refcounting in
- SetCurrentMenuBar and SetBaseMenuBar.
- <62> 6/30/95 RR 1242642 BB Ref counting fixes in
- HideODWindow.
- <61> 6/28/95 RR 1242642 BB Mostly ref counting. AddWindow
- and RemoveWindow adjust ref counts. Window
- iterator skips items marked for lazy
- deletion.
- <60> 6/26/95 TÇ 1242642 BB:Fix refcounting bugs
- <59> 6/25/95 TÇ 1242642 BB: Turn on ODDebug warning if
- refcount is wrong in
- ODRefCntObjectsomUninit.
- <58> 6/22/95 RR #1245283 Undoable frame deletion
- #1209427 Changed private api between
- iterator and iteratee. Allow deletion while
- iterating
- <57> 6/19/95 jpa Added hook to check for path pop-up
- (cmd-click title bar) [1259398]
- <56> 6/15/95 RR #1256879 Get->AcquireCurrentMenuBar
- <55> 6/8/95 RR #1257260 Collapse base classes. #1214898
- StdTypes.r -> ODTypes.r
- <54> 5/31/95 RR #1251403 Release after AcquirePart #1251980
- Missing release in GetFrontRootWindow
- <53> 5/26/95 RR #1251403: Multithreading naming support
- <52> 5/25/95 jpa List.h --> LinkList.h [1253324]
- <51> 5/17/95 RR #1250135/1250137/1250143 Getters increment
- refcount
- <50> 5/10/95 RR # 1234319. Check for rootFrameList before
- internalizing
- <49> 5/4/95 eeh 1242889: get drafts string from resource
- <48> 5/2/95 RR # 1244133 Fixed SetDefaultWindowTitles to
- avoid extra bogus characters
- <47> 4/28/95 RR 1211085 Remove 5$ comments
- <46> 4/14/95 TÇ With RR & CG: #1194507 DR/BB:title bar of a
- draft window doesn't reveal it is a draft
- or which draft it is
- <45> 4/13/95 RR #1216618 Added ODVolatile
- <44> 4/7/95 RR #1216618 Added SOM_TRY etc.
- <43> 4/6/95 RR # 1236361 Call Deactivate in HideODWindow.
- Remove redundant code to prevent
- deadstripping of PlatformFile
- <42> 4/4/95 RR # 1220104 Use ODObjectsAreEqual
- <41> 3/22/95 RR #1225420, 1227993 Parts internalize
- windows. Modified OpenWindow, Externalize,
- Internalize. Added RegisterWindowForFrame
- <40> 3/10/95 RR # 1225861 Send Suspend/resume to invisible
- windows
- <39> 3/7/95 RR # 1151165 Cleaned up AdjustPartMenus #
- 1220929 Added fMenuFocus
- <38> 3/3/95 CC # 1205622: Ensure activate event is
- delivered after modal dialog is dismissed.
- <37> 3/1/95 RR # 1205622 ::OpenWindows now supports
- re-opening an open draft by bringing its
- windows to the front.
- <36> 2/24/95 jpa Use ODNewRgn. [1220810]
- <35> 2/22/95 RR # 1213850 Call AdjustMenus for root part of
- active window before calling it for menu
- focus
- <34> 2/20/95 TÇ #1221861 BB: Incomplete AOCE support needs
- to be removed from OpenDoc
- <33> 1/31/95 RR # 1209165 Rewrote HandleAOCEEvent. #1209552
- Call SendBehind in HideODWindow
- <31> 1/26/95 VL #???: Use updated Storage Unit Ref API.
- <30> 1/25/95 RR #1211853 Removed session parameter from
- CreateMenuBar. Pass _fSession to
- InitMenuBar
- <29> 1/23/95 RR # 1211853 Added CreateMenuBar
- <28> 1/4/95 eeh 1209165: added test to
- HandleAOCEMailerEvent
- <27> 12/20/94 VL 1195012: Make Storage calls be
- marshallable.
- <26> 12/19/94 eeh 1192626: change ::Internalize not to
- duplicate windows already open
- <25> 11/28/94 RR Check for AOCE presence
- <24> 11/1/94 RR #1196761 Don't exit HandleAOCEMailerEvent
- without handling updates in inactive mailer
- windows
- <23> 10/18/94 RR Used AcquireWindow(id) to validate windows in
- CLoseWindows, in case part closed
- subsidiary windows
- <22> 9/29/94 RA 1189812: Mods for 68K build.
- <21> 9/23/94 VL 1155579, 1184272: Use StorUtil to
- create/get container and its file.
- <20> 9/22/94 eeh #1154961 AddAOCEMailer takes additional
- param.
- <19> 9/19/94 eeh #1164891: check for userCanceledErr after
- SMPMailerEvent call.
- <18> 9/1/94 RR #1176805 Release old base menu bar
- <17> 9/1/94 CC RADAR #1181971 - missing factory methods
- (for JBS)
- <16> 8/29/94 RR #1171772 DOn't call SelectWindow
- <15> 8/26/94 TÇ #1181761 rename obsolete kOD IDs to correct
- kODStrong/WeakStorageUnitRefs
- <14> 8/26/94 VL 1183174: Use updated cloning APIs.
- <13> 8/25/94 RR Added private AcquireBaseMenuBar. Set
- generation of menubar in SetBaseMenuBar
- <12> 8/19/94 TÇ #1180922 Need to Stop using obsolete types
- (kOD ID)
- <11> 8/18/94 jpa Filled in CreateCanvas [1180387]
- <10> 8/16/94 JBS 1180387: add CreateCanvas()
- <9> 8/15/94 JBS 1181138: add frameType to CreateFrame();
- 1181156: UI API Cleanup
- <8> 8/3/94 VL 1153123: Storage to ODStor.
- <7> 7/27/94 eeh fix use of Point and Rect (honesty to SOM…)
- <6> 7/21/94 eeh fix FixUpMailerWindow
- <5> 7/15/94 TÇ make sure PlatformFile code is not
- deadstripped
- <4> 7/8/94 RR Converted HandleAOCEMailerEvent
- <3> 6/27/94 eeh add Environment* parameters to
- AOCEHelperObj method calls
- <2> 9/27/94 RR Call InitBaseWindowState
- <1> 9/26/94 RR first checked in
-
- To Do:
- In Progress:
-
- */
-
-
- #define ODWindowState_Class_Source
- #define VARIABLE_MACROS
- #include <WinStat.xih>
-
- #ifndef SOM_ODWindowIterator_xh
- #include <WinIter.xh>
- #endif
-
- #ifndef _WINUTILM_
- #include "WinUtilM.h"
- #endif
-
- #ifndef _UIDEFS_
- #include "UIDefs.h"
- #endif
-
- #ifndef _TEMPOBJ_
- #include <TempObj.h>
- #endif
-
- #ifndef _STDTYPIO_
- #include <StdTypIO.h>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_ODWindow_xh
- #include <Window.xh>
- #endif
-
- #ifndef SOM_ODMenuBar_xh
- #include <MenuBar.xh>
- #endif
-
- #ifndef SOM_ODArbitrator_xh
- #include <Arbitrat.xh>
- #endif
-
- #ifndef SOM_Module_Apple_defined
- #include <Part.xh>
- #endif
-
- #ifndef SOM_ODFrame_xh
- #include <Frame.xh>
- #endif
-
- #ifndef SOM_ODFacet_xh
- #include <Facet.xh>
- #endif
-
- #ifndef SOM_ODCanvas_xh
- #include <Canvas.xh>
- #endif
-
- #ifndef SOM_ODDraft_xh
- #include <Draft.xh>
- #endif
-
- #ifndef SOM_ODDocument_xh
- #include <Document.xh>
- #endif
-
- #ifndef SOM_ODContainer_xh
- #include <ODCtr.xh>
- #endif
-
- #ifndef SOM_ODStorageSystem_xh
- #include <ODStor.xh>
- #endif
-
- #ifndef SOM_ODStorageUnit_xh
- #include <StorageU.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_Commands_defined
- #include <CmdDefs.xh>
- #endif
-
- #ifndef __GESTALTEQU__
- #include <GestaltEqu.h>
- #endif
-
- #ifndef _DLOGUTIL_
- #include <DlogUtil.h>
- #endif
-
- #ifndef _USERSRCM_
- #include <UseRsrcM.h>
- #endif
-
- #ifndef _PLFMFILE_
- #include <PlfmFile.h>
- #endif
-
- #ifndef _PASCLSTR_
- #include "PasclStr.h"
- #endif
-
- #ifndef _LINKLIST_
- #include <LinkList.h>
- #endif
-
- #ifndef _ORDCOLL_
- #include "OrdColl.h"
- #endif
-
- #ifndef _EXCEPT_
- #include "Except.h"
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdTypes_defined
- #include <StdTypes.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_Foci_defined
- #include <Foci.xh>
- #endif
-
- #ifndef _ODUTILS_
- #include <ODUtils.h>
- #endif
-
- #ifndef _STORUTIL
- #include <StorUtil.h>
- #endif
-
- #ifndef __LOWMEM__
- #include <LowMem.h> // For WindowList global
- #endif
-
- #ifndef __TOOLUTILS__
- #include <ToolUtils.h>
- #endif
-
- #ifndef _ODDEBUG_
- #include "ODDebug.h" // Adkins -- added
- #endif
-
- #ifndef _WINPOPM_
- #include "WinPopM.h"
- #endif
-
-
- // New Window API uses a new "WindowRef" type as an opaque window type. So that we can compile
- // with or without the new Windows.h, define WindowRef if it's not already defined: --jpa
- #ifndef STRICT_WINDOWS
- #define WindowRef WindowPeek
- #endif
-
- #define ODDebugActivates 0
-
- #pragma segment ODWindowState
-
- #include "WinStatB.cpp" // Platform-independent methods, if any
-
- static ODBoolean IsFrontProcess()
- {
- ProcessSerialNumber currentPSN;
- ProcessSerialNumber frontPSN;
- OSErr getFrontProcessResult;
- OSErr getCurrentProcessResult;
- ODBoolean isSameProcess = kODFalse;
-
- // Compare this process and the front process
- getFrontProcessResult = GetFrontProcess(&frontPSN);
- getCurrentProcessResult = GetCurrentProcess(¤tPSN);
-
- if ((getFrontProcessResult == noErr) && (getCurrentProcessResult == noErr))
- SameProcess(&frontPSN, ¤tPSN, &isSameProcess);
-
- return isSameProcess;
- }
-
-
- SOM_Scope void SOMLINK ODWindowStateDeactivateFrontWindows(ODWindowState *somSelf, Environment *ev)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateDeactivateFrontWindows");
-
- SOM_TRY
-
- WindowPtr firstDocWindow;
- WindowPtr secondDocWindow;
- WindowPtr window;
- WindowListIterator iter;
-
- firstDocWindow = somSelf->GetFrontNonFloatingPlatformWindow(ev);
- if (firstDocWindow != kODNULL)
- secondDocWindow = GetNextWindow(firstDocWindow);
-
- window = iter.First();
- while (iter.IsNotComplete() && (window != secondDocWindow))
- {
- if (GetWindowVisible(window) != kODFalse)
- {
- somSelf->DeactivateWindow(ev,window);
- }
- window = iter.Next();
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- SOM_Scope void SOMLINK ODWindowStateActivateFrontWindows(ODWindowState *somSelf, Environment *ev)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateActivateFrontWindows");
-
- SOM_TRY
-
- WindowPtr firstDocWindow;
- WindowPtr secondDocWindow;
- WindowPtr window;
- WindowListIterator iter;
-
- somSelf->RepairWindowOrder( ev );
-
- firstDocWindow = somSelf->GetFrontNonFloatingPlatformWindow(ev);
- if (firstDocWindow != kODNULL)
- secondDocWindow = GetNextWindow(firstDocWindow);
-
- window = iter.First();
- while (iter.IsNotComplete() && (window != secondDocWindow))
- {
- if (GetWindowVisible(window) != kODFalse)
- {
- somSelf->ActivateWindow(ev,window);
- }
- window = iter.Next();
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- SOM_Scope ODWindow* SOMLINK ODWindowStateAcquireFrontWindow(ODWindowState *somSelf, Environment *ev)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateAcquireFrontWindow");
-
- ODWindow* odWindow = kODNULL;
-
- SOM_TRY
-
- WindowPtr window = FrontWindow();
-
- if (window != kODNULL)
- {
- if (somSelf->IsODWindow(ev,window))
- odWindow = somSelf->AcquireODWindow(ev,window);
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- // AcquireODWindow increments ref count
- //if (odWindow)
- // odWindow->Acquire(ev);
- return odWindow;
- }
-
- SOM_Scope ODWindow* SOMLINK ODWindowStateAcquireFrontFloatingWindow(ODWindowState *somSelf, Environment *ev)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateAcquireFrontFloatingWindow");
-
- ODWindow* frontFloatingWindow = kODNULL;
-
- SOM_TRY
-
- WindowListIterator iter;
-
- WindowPtr platformWindow = iter.First();
- while (iter.IsNotComplete() && (frontFloatingWindow == kODNULL))
- {
- ODWindow* odWindow = somSelf->AcquireODWindow(ev,platformWindow);
- if (odWindow != kODNULL)
- {
- if (odWindow->IsFloating(ev) != kODFalse)
- {
- frontFloatingWindow = odWindow;
- }
- else
- {
- ODReleaseObject(ev, odWindow); // -- TÇ: released only if we don't want it.
- }
- }
- }
-
- SOM_CATCH_ALL
-
- frontFloatingWindow = kODNULL;
-
- SOM_ENDTRY
-
- // AcquireODWindow increments ref count
- //if (frontFloatingWindow)
- // frontFloatingWindow->Acquire(ev);
- return frontFloatingWindow;
- }
-
- SOM_Scope ODWindow* SOMLINK ODWindowStateAcquireFrontRootWindow(ODWindowState *somSelf, Environment *ev)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateAcquireFrontRootWindow");
-
- ODWindow* odWindow = kODNULL;
-
- SOM_TRY
-
- WindowListIterator iter;
-
- for (WindowPtr platformWindow = iter.First();
- iter.IsNotComplete();
- platformWindow = iter.Next())
- {
- odWindow = somSelf->AcquireODWindow(ev,platformWindow);
- if (odWindow && odWindow->IsRootWindow(ev))
- break;
- else
- ODReleaseObject(ev, odWindow);
- }
-
- SOM_CATCH_ALL
-
- odWindow = kODNULL;
-
- SOM_ENDTRY
-
- // AcquireODWindow increments ref count
- //if (odWindow)
- // odWindow->Acquire(ev);
- return odWindow; // -- TÇ: was acquired in the for loop above.
- }
-
- SOM_Scope void SOMLINK ODWindowStateInitWindowState(ODWindowState *somSelf, Environment *ev,
- ODSession* session)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateInitWindowState");
-
- LinkedList* linkedList = kODNULL; ODVolatile(linkedList);
-
- SOM_TRY
-
- /* Moved from somInit. SOM itself sets fields to zero
- _fWindowList = kODNULL;
- _fSession = kODNULL;
- _fBaseMenuBar = kODNULL;
- _fCurrentMenuBar = kODNULL;
- _fNextID = 0;
- _fMenuFocus = 0;
- _fIteratorCount = 0;
- */
-
- somSelf->InitObject(ev);
- _fSession = session;
- _fMenuFocus = _fSession->Tokenize(ev,kODMenuFocus);
- linkedList = new LinkedList;
- _fWindowList = linkedList;
-
- SOM_CATCH_ALL
-
- ODDeleteObject(linkedList);
-
- SOM_ENDTRY
- }
-
- SOM_Scope void SOMLINK ODWindowStateSetCurrentMenuBar(ODWindowState *somSelf, Environment *ev,
- ODMenuBar* theMenuBar)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateSetCurrentMenuBar");
-
- SOM_TRY
-
- if (!ODObjectsAreEqual(ev, _fCurrentMenuBar, theMenuBar))
- {
- ODReleaseObject(ev, _fCurrentMenuBar);
- if (theMenuBar)
- theMenuBar->Acquire(ev);
- _fCurrentMenuBar = theMenuBar;
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- SOM_Scope ODMenuBar* SOMLINK ODWindowStateAcquireCurrentMenuBar(ODWindowState *somSelf, Environment *ev)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateGetCurrentMenuBar");
-
- SOM_TRY
-
- if (_fCurrentMenuBar)
- _fCurrentMenuBar->Acquire(ev);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- return _fCurrentMenuBar;
- }
-
- SOM_Scope ODMenuBar* SOMLINK ODWindowStateAcquireBaseMenuBar(ODWindowState *somSelf, Environment *ev)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateAcquireBaseMenuBar");
-
- SOM_TRY
-
- if (_fBaseMenuBar)
- _fBaseMenuBar->Acquire(ev);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return _fBaseMenuBar;
- }
-
- SOM_Scope ODWindow* SOMLINK ODWindowStateAddWindow(ODWindowState *somSelf, Environment *ev,
- ODWindow* window)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateAddWindow");
-
- SOM_TRY
-
- if (window)
- {
- ODBoolean found = kODFalse;
- WindowLink* foundLink = kODNULL;
-
- LinkedListIterator iter(_fWindowList);
-
- for ( WindowLink* link = (WindowLink*) iter.First();
- iter.IsNotComplete();
- link = (WindowLink*) iter.Next())
- {
- if (!link->ShouldRemove() && ODObjectsAreEqual(ev, link->fWindow, window))
- {
- found = kODTrue;
- foundLink = link;
- break;
- }
- }
- if (!found)
- {
- // There is a problem here. We assume that the window is always going to be
- // in front. We may need to change the Window API to handle the case when
- // someone actually wants a window at the back.
-
- WindowPtr platformWindow = window->GetPlatformWindow(ev);
- WindowPtr lastFloatingWindow = somSelf->GetLastFloatingPlatformWindow(ev);
- if (lastFloatingWindow != kODNULL) {
- SendBehind(platformWindow, lastFloatingWindow);
- }
- else {
- BringToFront(platformWindow);
- }
-
- window->Acquire(ev);
- _fNextID++;
- WindowLink* link = new WindowLink(_fNextID, window);
- window->SetID(ev,_fNextID);
- THROW_IF_NULL(link);
- _fWindowList->AddLast(link);
- }
- }
-
- SOM_CATCH_ALL
-
- window = kODNULL;
-
- SOM_ENDTRY
-
- return window;
- }
-
- SOM_Scope void SOMLINK ODWindowStateRemoveWindow(ODWindowState *somSelf, Environment *ev,
- ODWindow* oldWindow)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateRemoveWindow");
-
- SOM_TRY
-
- ODBoolean found = kODFalse;
- WindowLink* foundLink = kODNULL;
-
- LinkedListIterator iter(_fWindowList);
-
- for ( WindowLink* link = (WindowLink*) iter.First();
- iter.IsNotComplete();
- link = (WindowLink*) iter.Next())
- {
- if (!link->ShouldRemove() && ODObjectsAreEqual(ev, link->fWindow, oldWindow))
- {
- found = kODTrue;
- foundLink = link;
- break;
- }
- }
- if (found)
- {
- ODWindow* window = foundLink->fWindow;
- ODReleaseObject(ev, window);
- if (_fIteratorCount > 0)
- {
- foundLink->fRemove = kODTrue;
- }
- else
- {
- _fWindowList->Remove(*foundLink);
- ODDeleteObject(foundLink);
- }
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- SOM_Scope ODWindow* SOMLINK ODWindowStateFindODWindow(ODWindowState *somSelf, Environment *ev,
- Point* globalPoint)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateFindODWindow");
-
- ODWindow* odWindow = kODNULL;
-
- SOM_TRY
-
- WindowPtr window;
- FindWindow(*globalPoint, &window);
- if (window)
- odWindow = somSelf->AcquireODWindow(ev,window);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return odWindow; // -- TÇ: ODWindowStateFindODWindow is an 'acquire' function
- }
-
- SOM_Scope void SOMLINK ODWindowStateReleaseWindow(ODWindowState *somSelf, Environment *ev,
- ODWindow* window)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateReleaseWindow");
-
- SOM_TRY
-
- ODDeleteObject(window);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- SOM_Scope void SOMLINK ODWindowStateSuspendResume(ODWindowState *somSelf, Environment *ev,
- ODEventData* event)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateSuspendResume");
-
- SOM_TRY
-
- const short kResumeMask = 0x01; // High byte suspend/resume event
-
- ODBoolean goingToBackground = (event->message & kResumeMask) == 0;
- // WindowPtr frontWindow = somSelf->GetFrontNonFloatingPlatformWindow(ev);
- //ODWindow* odWindow = kODNULL;
-
- #if ODDebug && ODDebugActivates
- somPrintf("WindowState Suspend/Resume %d\n", !goingToBackground);
- #endif
-
- ODWindowIterator* iter = somSelf->CreateWindowIterator(ev);
-
- for (ODWindow* window = iter->First(ev); iter->IsNotComplete(ev); window = iter->Next(ev))
- {
- window->SuspendResume(ev,event);
- }
- ODDeleteObject(iter);
-
- // Deactivate the front doc window and any floaters that haven't been hidden.
- // The system only unhilites the frontmost window
-
- if (goingToBackground)
- {
- #if ODDebug && ODDebugActivates
- somPrintf("WindowState Suspend Event - deactivate front windows\n");
- #endif
- somSelf->DeactivateFrontWindows(ev);
- }
- else
- {
- #if ODDebug && ODDebugActivates
- somPrintf("WindowState Resume Event - activate front windows\n");
- #endif
- somSelf->ActivateFrontWindows(ev);
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- SOM_Scope void SOMLINK ODWindowStateSelectODWindow(ODWindowState *somSelf, Environment *ev,
- ODWindow* window)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateSelectODWindow");
-
- SOM_TRY
-
- WindowPtr currentFrontWindow;
- WindowPtr lastFloatingWindow;
- Boolean isFloatingWindow;
- Boolean isFrontProcess;
- WindowPtr windowToSelect = window->GetPlatformWindow(ev);
-
- isFrontProcess = IsFrontProcess();
-
- if (window->IsFloating(ev) != kODFalse)
- {
- isFloatingWindow = kODTrue;
- currentFrontWindow = (WindowPtr) FrontWindow();
- }
- else
- {
- isFloatingWindow = kODFalse;
- currentFrontWindow = somSelf->GetFrontNonFloatingPlatformWindow(ev);
- lastFloatingWindow = somSelf->GetLastFloatingPlatformWindow(ev);
- }
-
- // Be fast (and lazy) and do nothing if we don’t have to.
- // The !IsActive test was added because this method might get called when
- // in the background during a Drop.
-
- if ((currentFrontWindow != windowToSelect) || (!window->IsActive(ev)))
- {
-
- // Selecting floating windows are easy, since they’re always active
-
- if (isFloatingWindow)
- {
- BringToFront(windowToSelect);
- }
- else
- {
- // This replaces the code below.
- // In order to facilitate a predictable flow of events,
- // we must use Macintosh Toolbox calls that don't generate activate
- // events themselves (ie. BringToFront, SendBehind).
-
- if (isFrontProcess)
- somSelf->DeactivateWindow(ev, currentFrontWindow);
-
- if (lastFloatingWindow == kODNULL)
- BringToFront(windowToSelect);
- else
- SendBehind(windowToSelect, lastFloatingWindow);
-
- //if (isFrontProcess) // Must allow activates for Drop in inactive window
- somSelf->ActivateWindow(ev,windowToSelect);
-
- }
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- } // SelectODWindow
-
-
- SOM_Scope void SOMLINK ODWindowStateDragODWindow(ODWindowState *somSelf, Environment *ev,
- ODWindow* window,
- Point* startPoint,
- Rect* draggingBounds)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateDragODWindow");
-
- SOM_TRY
-
- // Check for command-click on window title:
- if( TrackWindowPathPopUp(ev,window,*startPoint) )
- return;
-
- WindowPtr windowToDrag = window->GetPlatformWindow(ev);
- Rect dragRect;
- KeyMap keyMap;
- GrafPtr savePort;
- GrafPtr windowManagerPort;
- RgnHandle dragRegion;
- RgnHandle windowContentRegion;
- long dragResult;
- short topLimit;
- short newHorizontalWindowPosition;
- short newVerticalWindowPosition;
- short horizontalOffset;
- short verticalOffset;
- Boolean commandKeyDown = kODFalse;
-
- // Set up the Window Manager port.
- GetPort(&savePort);
- GetWMgrPort(&windowManagerPort);
- SetPort(windowManagerPort);
- SetClip(GetGrayRgn());
-
- // Check to see if the command key is down. If it is, don’t bring the window to the
- // front after the move.
- GetKeys(keyMap);
- if (keyMap[1] & 0x8000)
- commandKeyDown = kODTrue;
-
- if (WaitMouseUp())
- {
-
- // Adjust the top of the dragging rectangle so that it’s below the menu bar
- topLimit = LMGetMBarHeight() + 4;
- dragRect = *draggingBounds;
- if (dragRect.top < topLimit)
- dragRect.top = topLimit;
-
- if ((commandKeyDown != kODFalse) || (window->IsFloating(ev) == kODFalse))
- {
-
- if (commandKeyDown == kODFalse)
- // If there are floating windows, clip the dragging outline to draw behind the floaters.
- /* Adkins -- changed WindowPeek to WindowRef */
- ClipAbove((WindowRef) somSelf->GetFrontNonFloatingPlatformWindow(ev));
- else
- // If the command key was down, clip the outline to draw behind any windows above
- // the window being dragged.
- ClipAbove((WindowRef) windowToDrag); /* Adkins -- changed WindowPeek to WindowRef */
-
- }
-
- // Create a region to drag
- dragRegion = ODNewRgn();
- CopyRgn(GetStructureRegion(windowToDrag), dragRegion);
-
- // Drag the window around
- dragResult = DragGrayRgn(dragRegion, *startPoint, &dragRect, &dragRect, noConstraint, nil);
-
- // Restore the port right now for coordinate conversion.
- SetPort(savePort);
-
- if (dragResult != 0)
- {
- horizontalOffset = (ODSShort) (dragResult & 0xFFFF);
- verticalOffset = (ODSShort) (dragResult >> 16);
-
- // Only move it if it stayed inside the dragging box.
- if (verticalOffset != -32768)
- {
- windowContentRegion = GetContentRegion(windowToDrag);
- newHorizontalWindowPosition = (**windowContentRegion).rgnBBox.left + horizontalOffset;
- newVerticalWindowPosition = (**windowContentRegion).rgnBBox.top + verticalOffset;
-
- MoveWindow((WindowPtr) windowToDrag, newHorizontalWindowPosition, newVerticalWindowPosition, kODFalse);
-
- }
- }
-
- // Get rid of the dragging region
- DisposeRgn(dragRegion);
- }
-
- // Restore the port
- SetPort(savePort);
-
- // Bring the window forward if the command key wasn’t down
- if (commandKeyDown == kODFalse)
- somSelf->SelectODWindow(ev, window);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- SOM_Scope void SOMLINK ODWindowStateShowODWindow(ODWindowState *somSelf, Environment *ev,
- ODWindow* window)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateShowODWindow");
-
- SOM_TRY
-
- WindowPtr windowToShow = window->GetPlatformWindow(ev);
- WindowPtr windowBehind;
- ODBoolean windowIsInFront = kODFalse;
- ODBoolean isFrontProcess = IsFrontProcess();
-
- if (GetWindowVisible(windowToShow) == kODFalse)
- {
-
- // If the window behind the window to show is currently the frontmost document window,
- // unhighlight it, and highlight the new front window.
-
- if (window->IsFloating(ev) == kODFalse)
- {
- WindowPtr frontPlatformWindow = somSelf->GetFrontNonFloatingPlatformWindow(ev);
- if (frontPlatformWindow == kODNULL)
- windowIsInFront = kODTrue;
- else {
- windowBehind = GetNextWindow(windowToShow);
- if (windowBehind == frontPlatformWindow)
- {
- if (windowBehind != kODNULL)
- somSelf->DeactivateWindow(ev,windowBehind);
- windowIsInFront = kODTrue;
- }
- }
- }
- else
- {
-
- // A floating window is being shown. Should check to see if a modal window is up before
- // trying to highlight it.
-
- windowIsInFront = kODTrue;
- }
-
- if ( windowIsInFront && isFrontProcess )
- SetWindowHilite(windowToShow, kODTrue);
- else
- SetWindowHilite(windowToShow, kODFalse);
-
- // Show the window
-
- ShowHide(windowToShow, kODTrue);
-
- // If this is the new frontmost document window or a floating window, send it an activate event
-
- if ( windowIsInFront && isFrontProcess )
- {
- #if ODDebug && ODDebugActivates
- somPrintf("Activate in ShowODWindow for root frame %x\n", window->GetRootFrame(ev));
- #endif
- window->Activate(ev);
- }
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- // ref-count-neutral static function used in workaround in HideODWindow below
- static ODBoolean IsFloating(Environment* ev, ODWindowState* windowState, ODPlatformWindow win)
- {
- ODBoolean isFloating = kODFalse;
- ODWindow* window = windowState->AcquireODWindow(ev,win);
- if (window)
- isFloating = window->IsFloating(ev);
- ODReleaseObject(ev, window);
- return isFloating;
- }
-
- SOM_Scope void SOMLINK ODWindowStateHideODWindow(ODWindowState *somSelf, Environment *ev,
- ODWindow* window)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateHideODWindow");
-
- SOM_TRY
-
- WindowPtr windowToHide = window->GetPlatformWindow(ev);
- WindowPtr frontFloater;
- WindowPtr frontPlatformWindow;
- WindowPtr windowBehind;
-
-
- if (GetWindowVisible(windowToHide) != kODFalse)
- {
-
- // Get the first visible floating window, if any.
-
- frontFloater = (WindowPtr) FrontWindow();
-
- TempODWindow ODFrontFloater = somSelf->AcquireODWindow(ev,frontFloater);
- if ((ODFrontFloater != kODNULL) && (ODFrontFloater->IsFloating(ev) == kODFalse))
- frontFloater = nil;
-
- // Get the first visible document window, if any.
-
- frontPlatformWindow = somSelf->GetFrontNonFloatingPlatformWindow(ev);
-
- // Deactivate and Hide the window.
- somSelf->DeactivateWindow(ev,windowToHide);
-
- ShowHide(windowToHide, kODFalse);
-
- // If the frontmost floating window is being hidden, move it behind the floating window
- // behind it, if there is one.
-
- if (windowToHide == frontFloater)
- {
- windowBehind = GetNextWindow(windowToHide);
-
- // Only do the rearrangement if there’s another floating window.
-
- // if ((windowBehind != kODNULL) &&
- // (((ODWindowBehind = somSelf->AcquireODWindow(ev,windowBehind)) != kODNULL) &&
- // (ODWindowBehind->IsFloating() != kODFalse))) {
- // SetNextWindow(windowToHide, GetNextWindow(windowBehind));
- // SetNextWindow(windowBehind, windowToHide);
- // SetWindowList(windowBehind);
- // }
- }
- else
- {
-
- // If the frontmost document window is behind hidden, send it behind the window
- // behind it.
- TempODWindow ODWindowBehind = kODNULL;
-
- if (windowToHide == frontPlatformWindow)
- {
- windowBehind = windowToHide;
- /* $$$$$ Need to find out why this doesn't work, ref count wise
- do
- {
- windowBehind = GetNextWindow(windowBehind);
- if (somSelf->IsODWindow(ev,windowBehind))
- {
- ODReleaseObject(ev, ODWindowBehind); // Swapping references inside loop
- ODWindowBehind = somSelf->AcquireODWindow(ev,windowBehind);
- }
- else
- ODWindowBehind = kODNULL;
- }
- while (windowBehind &&
- (((ODWindowBehind == kODNULL) || (ODWindowBehind->IsFloating(ev))) ||
- (GetWindowVisible(windowBehind) == kODFalse)));
- */
-
- // Workaround for above loop, to avoid refcounted variable in loop
- // Is Floating is an rc-neutral static function above this method
- ODBoolean isODWindow = kODFalse;
- do
- {
- windowBehind = GetNextWindow(windowBehind);
- isODWindow = somSelf->IsODWindow(ev,windowBehind);
- }
- while (windowBehind &&
- (((isODWindow == kODFalse) || (IsFloating(ev, somSelf, windowBehind))) ||
- (GetWindowVisible(windowBehind) == kODFalse)));
- // End workaround
- if (windowBehind != kODNULL)
- {
- // Note: Experiment to fix #1209552. Using GetNextVisible instead of GetNext
- // might be better
-
- SendBehind(windowToHide, windowBehind);
-
- // The window behind it is now the front document window. Highlight it and send it
- // and activate event.
-
- if (IsFrontProcess())
- somSelf->ActivateWindow(ev,windowBehind);
- }
- }
-
- }
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- /*
- * for ODWindowIterator
- */
-
- SOM_Scope ODULong SOMLINK ODWindowStateAddIterator(ODWindowState *somSelf, Environment *ev,
- ODWindowIterator* iterator)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateAddIterator");
-
- LinkedListIterator* iter = kODNULL; ODVolatile(iter);
-
- SOM_TRY
-
- iter = new LinkedListIterator(_fWindowList);
- _fIteratorCount++;
-
- SOM_CATCH_ALL
-
- ODDeleteObject(iter);
-
- SOM_ENDTRY
-
- return (ODULong) iter;
- }
-
- SOM_Scope ODWindow* SOMLINK ODWindowStateFirst(ODWindowState *somSelf, Environment *ev,
- ODULong iteratorID)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateFirst");
-
- ODWindow* window = kODNULL;
-
- SOM_TRY
-
- LinkedListIterator* iterator = (LinkedListIterator*) iteratorID;
- WindowLink* link = (WindowLink*) iterator->First();
-
- while (link && link->ShouldRemove())
- link = (WindowLink*) iterator->Next();
-
- if (link)
- window = link->fWindow;
-
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return window;
- }
-
- SOM_Scope ODWindow* SOMLINK ODWindowStateNext(ODWindowState *somSelf, Environment *ev,
- ODULong iteratorID)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateNext");
-
- ODWindow* window = kODNULL;
-
- SOM_TRY
-
- LinkedListIterator* iterator = (LinkedListIterator*) iteratorID;
- WindowLink* link = (WindowLink*) iterator->Next();
-
- while (link && link->ShouldRemove())
- link = (WindowLink*) iterator->Next();
-
- if (link)
- window = link->fWindow;
-
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return window;
- }
-
- SOM_Scope ODWindow* SOMLINK ODWindowStateLast(ODWindowState *somSelf, Environment *ev,
- ODULong iteratorID)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateLast");
-
- ODWindow* window = kODNULL;
-
- SOM_TRY
-
- LinkedListIterator* iterator = (LinkedListIterator*) iteratorID;
- WindowLink* link = (WindowLink*) iterator->Last();
-
- while (link && link->ShouldRemove())
- link = (WindowLink*) iterator->Previous();
-
- if (link)
- window = link->fWindow;
-
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return window;
- }
-
- SOM_Scope ODWindow* SOMLINK ODWindowStatePrevious(ODWindowState *somSelf, Environment *ev,
- ODULong iteratorID)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStatePrevious");
-
- ODWindow* window = kODNULL;
-
- SOM_TRY
-
- LinkedListIterator* iterator = (LinkedListIterator*) iteratorID;
- WindowLink* link = (WindowLink*) iterator->Previous();
-
- while (link && link->ShouldRemove())
- link = (WindowLink*) iterator->Previous();
-
- if (link)
- window = link->fWindow;
-
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return window;
- }
-
- SOM_Scope ODBoolean SOMLINK ODWindowStateIsNotComplete(ODWindowState *somSelf, Environment *ev,
- ODULong iteratorID)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateIsNotComplete");
-
- ODBoolean isNotComplete = kODFalse;
-
- SOM_TRY
-
- LinkedListIterator* iterator = (LinkedListIterator*) iteratorID;
- isNotComplete = iterator->IsNotComplete();
-
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return isNotComplete;
- }
-
- SOM_Scope void SOMLINK ODWindowStateRemoveIterator(ODWindowState *somSelf, Environment *ev,
- ODULong iteratorID)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateRemoveIterator");
-
- SOM_TRY
-
- LinkedListIterator* iterator = (LinkedListIterator*) iteratorID;
- ODDeleteObject(iterator);
- _fIteratorCount--;
-
- if (_fIteratorCount == 0) // Clear items marked for deletion during iteration
- {
- LinkedListIterator iter(_fWindowList);
- for ( WindowLink* link = (WindowLink*) iter.First();
- iter.IsNotComplete();
- link = (WindowLink*) iter.Next())
- {
- if (link->ShouldRemove())
- {
- iter.RemoveCurrent();
- delete link;
- }
- }
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
-
- SOM_Scope void SOMLINK ODWindowStateActivateWindow(ODWindowState *somSelf, Environment *ev,
- ODPlatformWindow platformWindow)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateActivateWindow");
-
- SOM_TRY
-
- somSelf->HighlightAndActivateWindow(ev, platformWindow, kODTrue);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- SOM_Scope void SOMLINK ODWindowStateDeactivateWindow(ODWindowState *somSelf, Environment *ev,
- ODPlatformWindow platformWindow)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateDeactivateWindow");
-
- SOM_TRY
-
- somSelf->HighlightAndActivateWindow(ev, platformWindow, kODFalse);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- SOM_Scope void SOMLINK ODWindowStateHighlightAndActivateWindow(ODWindowState *somSelf, Environment *ev,
- ODPlatformWindow platformWindow,
- ODBoolean activate)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateHighlightAndActivateWindow");
-
- SOM_TRY
-
- #if ODDebug && ODDebugActivates
- somPrintf("Activate/Deactivate message from OpenDoc\n");
- #endif
-
- // Note: This optimization doesn't work if we don't dispatch
- // activate events from the Toolbox. eg. if you dismiss a modal dialog
- // the activate calls below don't get made because the Toolbox must have already
- // tweaked the highlighting.
-
- //if (AcquireWindowHilite(platformWindow) != activate)
- {
- HiliteWindow( platformWindow, IsFrontProcess() ? activate : kODFalse );
-
- if (somSelf->IsODWindow(ev,platformWindow) != kODFalse)
- {
-
- TempODWindow odWindow = somSelf->AcquireODWindow(ev,platformWindow);
- if (activate == kODFalse)
- {
- #if ODDebug && ODDebugActivates
- somPrintf("Deactivate message from OpenDoc for root frame %x\n", odWindow->GetRootFrame(ev));
- #endif
- odWindow->Deactivate(ev);
- }
- else
- {
- #if ODDebug && ODDebugActivates
- somPrintf("Activate message from OpenDoc for root frame %x\n", odWindow->GetRootFrame(ev));
- #endif
- odWindow->Activate(ev);
- }
- }
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- SOM_Scope ODPlatformWindow SOMLINK ODWindowStateGetLastFloatingPlatformWindow(ODWindowState *somSelf, Environment *ev)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateGetLastFloatingPlatformWindow");
-
- WindowPtr lastFloatingWindow = kODNULL;
-
- SOM_TRY
-
- WindowPtr theWindow;
- ODWindow* odWindow;
-
- theWindow = ::GetWindowList();
- lastFloatingWindow = kODNULL;
-
- // We have to search the entire window list because we don’t know what the windowKind
- // of other windows in the list might be, and we have account for the fact that a modal
- // dialog is up.
-
- while (theWindow != kODNULL)
- {
- if (somSelf->IsODWindow(ev,theWindow) != kODFalse)
- {
- odWindow = somSelf->AcquireODWindow(ev,theWindow);
- if (odWindow->IsFloating(ev) != kODFalse)
- lastFloatingWindow = theWindow;
- ODReleaseObject(ev, odWindow);
- }
- theWindow = GetNextWindow(theWindow);
- }
-
- SOM_CATCH_ALL
-
- lastFloatingWindow = kODNULL;
-
- SOM_ENDTRY
-
- return lastFloatingWindow;
- }
-
- SOM_Scope ODPlatformWindow SOMLINK ODWindowStateGetFrontNonFloatingPlatformWindow(ODWindowState *somSelf, Environment *ev)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateGetFrontNonFloatingPlatformWindow");
-
-
- WindowPtr theWindow = kODNULL;
- ODVolatile(theWindow);
-
- SOM_TRY
-
- TempODWindow odWindow = kODNULL;
-
- // Get the first visible window in the window list.
-
- theWindow = FrontWindow();
-
- // Keep searching until a visible window whose windowKind is not
- // kApplicationFloaterKind is found, or the end of the window list is reached.
-
- while ((theWindow != kODNULL) &&
- (((odWindow = somSelf->AcquireODWindow(ev,theWindow)) != kODNULL) && /* -- TÇ:released down below */
- (odWindow->IsFloating(ev) != kODFalse)))
- {
- ODReleaseObject(ev, odWindow); // -- TÇ: to balance the above acquire
- do
- {
- theWindow = GetNextWindow(theWindow);
- }
- while ((theWindow != kODNULL) && (GetWindowVisible(theWindow) == kODFalse));
- }
-
-
- SOM_CATCH_ALL
-
- theWindow = kODNULL;
-
- SOM_ENDTRY
-
- // odWindow is released here on destruction of the TempODWindow, if not in the loop above
- return theWindow;
-
- }
-
- SOM_Scope void SOMLINK ODWindowStatesomUninit(ODWindowState *somSelf)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStatesomUninit");
-
- Environment* ev = somGetGlobalEnvironment();
-
- ODDeleteObject(_fWindowList);
- ODSafeReleaseObject(_fBaseMenuBar); _fBaseMenuBar = kODNULL;
- ODSafeReleaseObject(_fCurrentMenuBar); _fCurrentMenuBar = kODNULL;
- }
-
- SOM_Scope ODSize SOMLINK ODWindowStatePurge(ODWindowState *somSelf, Environment *ev,
- ODSize size)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStatePurge");
-
- return 0;
- }
-
- SOM_Scope ODWindow* SOMLINK ODWindowStateRegisterWindow(ODWindowState *somSelf, Environment *ev,
- ODPlatformWindow newWindow,
- ODType frameType,
- ODBoolean isRootWindow,
- ODBoolean isResizable,
- ODBoolean isFloating,
- ODBoolean shouldSave,
- ODBoolean shouldDispose,
- ODPart* rootPart,
- ODTypeToken viewType,
- ODTypeToken presentation,
- ODFrame* sourceFrame)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateCreateWindow");
-
- ODWindow* window = kODNULL; ODVolatile(window);
-
- SOM_TRY
-
- window = new ODWindow();
- if (window == kODNULL)
- THROW(kODErrCannotCreateWindow); // Note: Should we just use kODErrOutOfMemory?
-
- window->InitWindow(ev, newWindow, frameType,
- isRootWindow, isResizable, isFloating, shouldSave, shouldDispose,
- rootPart, viewType, presentation, sourceFrame);
- somSelf->AddWindow(ev,window);
-
- SOM_CATCH_ALL
-
- if (window)
- {
- TRY
- window->CloseAndRemove(ev);
- CATCH_ALL
- ENDTRY
- window = kODNULL;
- }
-
- SOM_ENDTRY
-
- return window;
- }
-
- SOM_Scope ODWindow* SOMLINK ODWindowStateRegisterWindowForFrame(ODWindowState *somSelf, Environment *ev,
- ODPlatformWindow newWindow,
- ODFrame* frame,
- ODBoolean isRootWindow,
- ODBoolean isResizable,
- ODBoolean isFloating,
- ODBoolean shouldSave,
- ODBoolean shouldDispose,
- ODFrame* sourceFrame)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateCreateWindow");
-
- ODWindow* window = kODNULL; ODVolatile(window);
-
- SOM_TRY
-
- window = new ODWindow();
- if (window == kODNULL)
- THROW(kODErrCannotCreateWindow); // Note: Should we just use kODErrOutOfMemory?
-
- window->InitWindowForFrame(ev, newWindow, frame,
- isRootWindow, isResizable, isFloating, shouldSave, shouldDispose, sourceFrame);
- somSelf->AddWindow(ev,window);
-
- SOM_CATCH_ALL
-
- if (window)
- {
- TRY
- window->Close(ev);
- CATCH_ALL
- ENDTRY
- window = kODNULL;
- }
-
- SOM_ENDTRY
-
- return window;
- }
-
- SOM_Scope ODWindow* SOMLINK ODWindowStateAcquireWindow(ODWindowState *somSelf, Environment *ev,
- ODID id)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateAcquireWindow");
-
- ODWindow* window = kODNULL;
-
- SOM_TRY
-
- /* LinkedListIterator iter(_fWindowList);
-
- for ( WindowLink* link = (WindowLink*) iter.First();
- iter.IsNotComplete();
- link = (WindowLink*) iter.Next())
- {
- if (!link->ShouldRemove() && (link->fID == id))
- {
- window = link->fWindow;
- break;
- }
- }
- */
- ODWindowIterator* iter = kODNULL;
-
- iter = somSelf->CreateWindowIterator(ev);
-
- for (ODWindow* win = iter->First(ev); iter->IsNotComplete(ev);
- win = iter->Next(ev))
- {
- if (win->GetID(ev) == id)
- {
- window = win;
- break;
- }
- }
- ODDeleteObject(iter);
-
- if (window)
- window->Acquire(ev);
-
- SOM_CATCH_ALL
-
- window = kODNULL;
-
- SOM_ENDTRY
-
- return window;
- }
-
- SOM_Scope void SOMLINK ODWindowStateInternalize(ODWindowState *somSelf, Environment *ev,
- ODDraft* draft)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateInternalize");
-
- OrderedCollection* wsuIDCollection = kODNULL; ODVolatile(wsuIDCollection);
-
- SOM_TRY
-
- // To avoid calling Select in OpenWindows, we use this piece of cross-method state
- // A better solution might be to change ODOpenDraft to distinguish between the
- // opendraft and activateopendraft (from the dialog) cases. See also #1295739
-
- _fActivateOnOpen = (somSelf->GetRootWindowCount(ev, draft) > 0);
-
- ODULong offset, offsetLimit;
- ODStorageUnitRef suRef;
-
- TempODStorageUnit draftProps = draft->AcquireDraftProperties(ev); // -- TÇ tempobj'd
-
- if (ODSUExistsThenFocus(ev, draftProps,kODPropRootFrameList, kODStrongStorageUnitRefs))
- {
- offsetLimit = draftProps->GetSize(ev);
-
- // Get collection of windowstorageunit ids belonging to the draft here. We'll
- // use it below to ensure that we don't reopen open windows.
-
- wsuIDCollection = new OrderedCollection;
- WindowPtr theWindow = ::GetWindowList();
- while (theWindow != kODNULL)
- {
- if (somSelf->IsODWindow(ev,theWindow) != kODFalse)
- {
- TempODWindow odWindow = somSelf->AcquireODWindow(ev,theWindow);
- if ( ODObjectsAreEqual(ev, odWindow->GetDraft(ev) , draft) )
- {
- ODStorageUnit* storageU = odWindow->GetRootFrame(ev)->GetStorageUnit(ev);
- if ( storageU )
- wsuIDCollection->AddLast( (ElementType)(storageU->GetID(ev)) );
- }
- }
- theWindow = GetNextWindow(theWindow);
- }
-
- TempODStorageUnitView draftPropsView = draftProps->CreateView(ev);
- for (offset = 0; offset < offsetLimit; offset += sizeof(ODStorageUnitRef))
- {
- draftPropsView->SetOffset(ev,offset);
- StorageUnitViewGetValue(draftPropsView,ev,sizeof(ODStorageUnitRef), (ODValue)&suRef);
- if (draftPropsView->IsValidStorageUnitRef(ev, suRef))
- {
- ODStorageUnitID wsuID = draftPropsView->GetIDFromStorageUnitRef(ev,suRef);
- if ( !wsuIDCollection->Contains((ElementType)wsuID) )
- {
- ODFrame *rootFrame = draft->AcquireFrame(ev, wsuID);
- if (rootFrame)
- {
- TRY{
- TempODPart rootPart = rootFrame->AcquirePart(ev);
- rootPart->Open(ev, rootFrame);
- }CATCH_ALL{
- TRY
- rootFrame->Close(ev);
- CATCH_ALL
- ENDTRY
- RERAISE;
- }ENDTRY
- rootFrame->Release(ev);
- }
- }
- }
- }
- ODDeleteObject(wsuIDCollection);
-
- somSelf->SetDefaultWindowTitles(ev,draft);
- }
-
- SOM_CATCH_ALL
-
- ODDeleteObject(wsuIDCollection);
-
- SOM_ENDTRY
- }
-
- SOM_Scope void SOMLINK ODWindowStateExternalize(ODWindowState *somSelf, Environment *ev,
- ODDraft* draft)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateExternalize");
-
- SOM_TRY
-
- somSelf->SetDefaultWindowTitles(ev,draft);
-
- ODULong offset, offsetLimit;
- ODFrame* rootFrame = kODNULL;
-
- TempODStorageUnit draftProps = draft->AcquireDraftProperties(ev);
-
- ODSUForceFocus(ev, draftProps, kODPropRootFrameList, kODStrongStorageUnitRefs);
-
- offset = 0;
- offsetLimit = draftProps->GetSize(ev);
-
- // Use the Window Manager list, since it's ordered
- // Note: we write the windows out back to front, since we create them in internalize
- // with the "behind" pointer -1. This only works because ShowODWindow does not bring
- // the newly shown window in front of the other invisible ones, as does ShowWindow.
-
- WindowListIterator iter;
-
- for (WindowPtr window = iter.Last(); iter.IsNotComplete(); window = iter.Previous())
- {
- if (somSelf->IsODWindow(ev,window))
- {
- TempODWindow odWindow = somSelf->AcquireODWindow(ev,window); // DMc refcount - make temp
- if (odWindow
- && (odWindow->ShouldSave(ev))
- && (ODObjectsAreEqual(ev, odWindow->GetDraft(ev), draft)))
- {
- if (odWindow->GetStorageUnit(ev) == kODNULL)
- {
- TempODStorageUnit su = draft->CreateStorageUnit(ev);
- odWindow->SetStorageUnit(ev, su);
- }
- odWindow->Externalize(ev);
-
- rootFrame = odWindow->GetRootFrame(ev);
- draftProps->SetOffset(ev,offset); // $opt: Won't the offset be correct automatically? -TC
- ODSetStrongSURefProp(ev, draftProps, kODNULL, kODNULL, rootFrame->GetStorageUnit(ev)->GetID(ev));
- offset += sizeof(ODStorageUnitRef); // $opt: Won't the offset be correct automatically? -TC
- }
- }
- }
-
- if (offset < offsetLimit)
- draftProps->DeleteValue(ev,offsetLimit - offset);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- SOM_Scope void SOMLINK ODWindowStateSetDefaultWindowTitles(ODWindowState *somSelf, Environment *ev,
- ODDraft* draft)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateSetDefaultWindowTitles");
-
- //!!! Needs work. Should add counter
- // Sets default window titles for all root windows of the given draft,
- // based on the file name.
-
- ODWindowIterator* iter = kODNULL; ODVolatile(iter);
- PlatformFile* file = kODNULL; ODVolatile(file);
-
- SOM_TRY
-
- ODContainer* container = draft->GetDocument(ev)->GetContainer(ev);
-
- file = GetPlatformFileFromContainer(ev, container);
-
- char windowName[256];
-
- iter = somSelf->CreateWindowIterator(ev);
-
- for (ODWindow* window = iter->First(ev); iter->IsNotComplete(ev);
- window = iter->Next(ev))
- {
- if ( (ODObjectsAreEqual(ev, window->GetDraft(ev), draft)) && window->IsRootWindow(ev) )
- {
- file->GetAsciiName(windowName,235);
-
- ODULong draftNum = 0;
-
- TRY
- draftNum = GetDraftNumFromDraft(ev, draft);
- CATCH_ALL
- ENDTRY
-
- if (draftNum != 0)
- {
- CToPascalString(windowName);
-
- const ODSShort kMaxNumberSuffixLength = 10;
- char theNum[kMaxNumberSuffixLength];
- NumToString(draftNum, (StringPtr)theNum); // Macintosh Specific
-
- ODSLong savedRefNum;
- BeginUsingLibraryResources(savedRefNum);
- ReplaceIntoString( kODDraftTextResID, (StringPtr)windowName,
- (StringPtr)theNum, (StringPtr)windowName );
- EndUsingLibraryResources(savedRefNum);
- PascalToCString((StringPtr)windowName);
- }
-
- window->SetWindowTitle(ev, windowName);
- }
- }
- ODDeleteObject(iter);
- ODDeleteObject(file);
-
- SOM_CATCH_ALL
-
- ODDeleteObject(iter);
- ODDeleteObject(file);
-
- SOM_ENDTRY
- }
-
- SOM_Scope void SOMLINK ODWindowStateOpenWindows(ODWindowState *somSelf, Environment *ev,
- ODDraft* draft)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateOpenWindows");
-
- ODWindowIterator* iter = kODNULL; ODVolatile(iter);
-
- SOM_TRY
-
- if (draft)
- {
- iter = somSelf->CreateWindowIterator(ev);
-
- // Windows were externalize/internalized back to front
- for (ODWindow* window = iter->First(ev); iter->IsNotComplete(ev);
- window = iter->Next(ev))
- {
- if (ODObjectsAreEqual(ev, window->GetDraft(ev) , draft))
- {
- window->Open(ev); // A no-op if its already open
- if (_fActivateOnOpen && window->IsShown(ev)) // The draft is already open
- window->Select(ev);
- }
- }
- ODDeleteObject(iter);
- }
- _fActivateOnOpen = kODFalse;
-
- SOM_CATCH_ALL
-
- _fActivateOnOpen = kODFalse;
- ODDeleteObject(iter);
-
- SOM_ENDTRY
-
- }
-
- SOM_Scope void SOMLINK ODWindowStateCloseWindows(ODWindowState *somSelf, Environment *ev,
- ODDraft* draft)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateCloseWindows");
-
- SOM_TRY
-
- // For now, since we can't delete while iterating, we make a copy of the list. Yuck.
-
- /* LinkedList windowListCopy;
-
- {
- LinkedListIterator iter(_fWindowList);
-
- for ( WindowLink* link = (WindowLink*) iter.First();
- iter.IsNotComplete();
- link = (WindowLink*) iter.Next())
- {
- WindowLink* linkCopy = new WindowLink(link->fID, link->fWindow);
- THROW_IF_NULL(linkCopy);
- windowListCopy.AddLast(linkCopy);
- }
- }
-
- LinkedListIterator citer(&windowListCopy);
- for ( WindowLink* clink = (WindowLink*) citer.First();
- citer.IsNotComplete();
- clink = (WindowLink*) citer.Next())
- {
- // Note: Use ID check in case Part closed a subsidiary window
- // This works now because this is a copy of the list.
- // Should probably do a deferred close scheme instead
-
- ODWindow* window = somSelf->AcquireWindow(ev, clink->fID);
- // ODWindow* window = link->fWindow;
- if (window && (ODObjectsAreEqual(ev, window->GetDraft(ev), draft )))
- {
- window->Close(ev);
- }
- ODReleaseObject(ev, window);
- }
- windowListCopy.DeleteAllLinks();
- */
-
- ODWindowIterator* iter = somSelf->CreateWindowIterator(ev);
-
- for (ODWindow* window = iter->First(ev); iter->IsNotComplete(ev); window = iter->Next(ev))
- {
- if (ODObjectsAreEqual(ev, window->GetDraft(ev), draft ))
- {
- window->Acquire(ev); // Close Releases
- window->Close(ev);
- }
- }
- ODDeleteObject(iter);
-
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- SOM_Scope ODUShort SOMLINK ODWindowStateGetWindowCount(ODWindowState *somSelf, Environment *ev)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateGetWindowCount");
-
- ODUShort count = 0;
-
- SOM_TRY
-
- if (_fWindowList)
- count = _fWindowList->Count();
-
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return count;
- }
-
- SOM_Scope ODUShort SOMLINK ODWindowStateGetRootWindowCount(ODWindowState *somSelf, Environment *ev,
- ODDraft* draft)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateGetRootWindowCount");
-
- ODUShort count = 0;
- ODWindowIterator* iter = kODNULL; ODVolatile(iter);
-
- SOM_TRY
-
- if (draft)
- {
- iter = somSelf->CreateWindowIterator(ev);
-
- for (ODWindow* window = iter->First(ev); iter->IsNotComplete(ev);
- window = iter->Next(ev))
- {
- if (window->IsRootWindow(ev) && (ODObjectsAreEqual(ev, window->GetDraft(ev), draft)))
- {
- count++;
- }
- }
- ODDeleteObject(iter);
- }
-
- SOM_CATCH_ALL
-
- ODDeleteObject(iter);
-
- SOM_ENDTRY
-
- return count;
- }
-
- SOM_Scope ODUShort SOMLINK ODWindowStateGetTotalRootWindowCount(ODWindowState *somSelf, Environment *ev)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateGetTotalRootWindowCount");
-
- //!!! Should get count directly from collection
-
- ODUShort count = 0;
- ODWindowIterator* iter = kODNULL; ODVolatile(iter);
-
- SOM_TRY
-
- iter = somSelf->CreateWindowIterator(ev);
-
- for (ODWindow* window = iter->First(ev); iter->IsNotComplete(ev);
- window = iter->Next(ev))
- {
- if (window->IsRootWindow(ev))
- count++;
- }
- ODDeleteObject(iter);
-
- SOM_CATCH_ALL
-
- ODDeleteObject(iter);
-
- SOM_ENDTRY
-
- return count;
- }
-
- SOM_Scope ODBoolean SOMLINK ODWindowStateIsODWindow(ODWindowState *somSelf, Environment *ev,
- ODPlatformWindow aWindow)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateIsODWindow");
-
- ODWindowIterator* iter = kODNULL; ODVolatile(iter);
- ODBoolean isODWindow = kODFalse;
-
- SOM_TRY
-
- iter = somSelf->CreateWindowIterator(ev);
-
- for (ODWindow* window = iter->First(ev); iter->IsNotComplete(ev);
- window = iter->Next(ev))
- {
- if (window && (aWindow == window->GetPlatformWindow(ev)))
- {
- isODWindow = kODTrue;
- break;
- }
- }
- ODDeleteObject(iter);
-
-
- SOM_CATCH_ALL
-
- ODDeleteObject(iter);
-
- SOM_ENDTRY
-
- return isODWindow;
- }
-
- SOM_Scope ODWindow* SOMLINK ODWindowStateAcquireODWindow(ODWindowState *somSelf, Environment *ev,
- ODPlatformWindow aWindow)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateAcquireODWindow");
-
- ODWindowIterator* iter = kODNULL; ODVolatile(iter);
- ODWindow* odWindow = kODNULL;
-
- SOM_TRY
-
- iter = somSelf->CreateWindowIterator(ev);
-
- for (ODWindow* window = iter->First(ev); iter->IsNotComplete(ev);
- window = iter->Next(ev))
- {
- if (window && (aWindow == window->GetPlatformWindow(ev)))
- {
- odWindow = window;
- break;
- }
- }
- ODDeleteObject(iter);
-
- if (odWindow)
- odWindow->Acquire(ev);
-
- SOM_CATCH_ALL
-
- ODDeleteObject(iter);
- odWindow = kODNULL;
-
- SOM_ENDTRY
-
- return odWindow;
- }
-
- SOM_Scope ODWindowIterator* SOMLINK ODWindowStateCreateWindowIterator(ODWindowState *somSelf, Environment *ev)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateCreateWindowIterator");
-
- ODWindowIterator* iter = kODNULL; ODVolatile(iter);
-
- SOM_TRY
-
- iter = new ODWindowIterator;
- THROW_IF_NULL(iter); // "new" does not throw for SOM objects
- iter->InitWindowIterator(ev, somSelf);
-
- SOM_CATCH_ALL
-
- ODDeleteObject(iter);
-
- SOM_ENDTRY
-
- return iter;
- }
-
- SOM_Scope ODWindow* SOMLINK ODWindowStateAcquireActiveWindow(ODWindowState *somSelf, Environment *ev)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateAcquireActiveWindow");
-
- ODWindow* aWindow = kODNULL;
-
- SOM_TRY
-
- WindowPtr platformWindow = kODNULL;
-
- // • First we need to find out the frontmost window
- platformWindow = somSelf->GetFrontNonFloatingPlatformWindow(ev);
-
- if (platformWindow)
- aWindow = somSelf->AcquireODWindow(ev,platformWindow);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- // Not necessary to increment ref count, because AcquireODWindow has done it
- //if (aWindow)
- // aWindow->Acquire(ev);
- return aWindow;
- }
-
- SOM_Scope void SOMLINK ODWindowStateSetBaseMenuBar(ODWindowState *somSelf, Environment *ev,
- ODMenuBar* theMenuBar)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateSetBaseMenuBar");
-
- SOM_TRY
-
- // $$$$$ Change this error code to be more explicit. -VL
- ASSERT(theMenuBar, kODErrIllegalNullInput);
-
- if (!ODObjectsAreEqual(ev, theMenuBar, _fBaseMenuBar))
- {
- ODULong generation;
- if (_fBaseMenuBar)
- generation = _fBaseMenuBar->GetGeneration(ev) + 1;
- else
- generation = 1;
- ODReleaseObject(ev, _fBaseMenuBar);
- theMenuBar->Acquire(ev);
- _fBaseMenuBar = theMenuBar;
- _fBaseMenuBar->SetGeneration(ev,generation);
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- SOM_Scope ODMenuBar* SOMLINK ODWindowStateCopyBaseMenuBar(ODWindowState *somSelf, Environment *ev)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateCopyBaseMenuBar");
-
- ODMenuBar* menuBar = kODNULL;
-
- SOM_TRY
-
- if (_fBaseMenuBar)
- menuBar = _fBaseMenuBar->Copy(ev);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return menuBar; // -- TÇ: CopyBaseMenuBar is an 'acquire' function.
- }
-
- SOM_Scope void SOMLINK ODWindowStateAdjustPartMenus(ODWindowState *somSelf, Environment *ev)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateAdjustPartMenus");
-
- SOM_TRY
-
- TempODFrame targetFrame
- = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev,_fMenuFocus);
-
- // To support root menu items like Print.
- // Other platforms may choose to add a new focus for this
-
- ODFrame* rootFrame;
- { TempODWindow window = somSelf->AcquireActiveWindow(ev) ;
- rootFrame = window ? window->GetRootFrame(ev) : kODNULL;
- }
-
- if (rootFrame)
- {
- TempODPart targetPart = rootFrame->AcquirePart(ev); // -- TÇ tempobj'd
- targetPart->AdjustMenus(ev,rootFrame);
- }
-
- if (targetFrame && (targetFrame != rootFrame))
- {
- TempODPart targetPart = targetFrame->AcquirePart(ev); // -- TÇ tempobj'd
- targetPart->AdjustMenus(ev,targetFrame);
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- SOM_Scope ODMenuBar* SOMLINK ODWindowStateCreateMenuBar(ODWindowState *somSelf, Environment *ev,
- ODPlatformMenuBar menuBar)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateCreateMenuBar");
-
- ODMenuBar* mb = kODNULL; ODVolatile(mb);
-
- SOM_TRY
-
- mb = new ODMenuBar;
- THROW_IF_NULL(mb); // "new" does not THROW for SOM objects
- mb->InitMenuBar(ev, _fSession, menuBar);
-
- SOM_CATCH_ALL
-
- ODDeleteObject(mb);
-
- SOM_ENDTRY
-
- return mb;
- }
-
- SOM_Scope ODCanvas* SOMLINK ODWindowStateCreateCanvas(ODWindowState *somSelf, Environment *ev,
- ODGraphicsSystem graphicsSystem,
- ODPlatformCanvas platformCanvas,
- ODBoolean isDynamic,
- ODBoolean isOffscreen)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","CreateCanvas");
-
- ODCanvas* canvas = kODNULL; ODVolatile(canvas);
-
- SOM_TRY
-
- canvas = new ODCanvas;
- THROW_IF_NULL(canvas); // "new" does not THROW for SOM objects
- canvas->InitCanvas(ev, graphicsSystem,platformCanvas,isDynamic,isOffscreen);
-
- SOM_CATCH_ALL
-
- ODDeleteObject(canvas);
-
- SOM_ENDTRY
-
- return canvas;
- }
-
- SOM_Scope ODFacet* SOMLINK ODWindowStateCreateFacet(ODWindowState *somSelf, Environment *ev,
- ODFrame* frame,
- ODShape* clipShape,
- ODTransform* externalTransform,
- ODCanvas* canvas,
- ODCanvas* biasCanvas)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","CreateFacet");
-
- ODFacet* facet = kODNULL; ODVolatile(facet);
-
- SOM_TRY
-
- facet = new ODFacet;
- THROW_IF_NULL(facet); // "new" does not THROW for SOM objects
- facet->InitFacet(ev, frame, clipShape, externalTransform, canvas, biasCanvas);
-
- SOM_CATCH_ALL
-
- ODDeleteObject(facet);
-
- SOM_ENDTRY
-
- return facet;
- }
-
- SOM_Scope void SOMLINK ODWindowStateRepairWindowOrder(ODWindowState *somSelf, Environment *ev)
- {
- ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
- ODWindowStateMethodDebug("ODWindowState","ODWindowStateRepairWindowOrder");
-
- // ODWindowState calls this private method when it suspects that some alien code
- // (the toolbox or an INIT) has messed with the Window Manager window list behind
- // its back. This method will force all non-floating ODWindows to be behind all
- // floating ODWindows. Non-ODWindows are ignored.
- //
- // BUG: If there are nested dialogs,
- // AND the inner dialog calls ActivateFrontWindows (which calls this method) upon
- // dismissal (which it should), AND the outer dialog (which is now the top window) is
- // an ODWindow, then this method will move the outer dialog to appear behind the floaters.
- // There is currently no way to tell that a non-floating window is actually a modal
- // dialog window. It turns out that this behavior shouldn't be a problem: because the
- // outer dialog is an ODWindow, it's frame will take the selection focus, causing
- // all floaters owned by other frames to be hidden. Thus, when the inner dialog is
- // dismissed, the outer dialog is forced behind the floaters, but they are hidden,
- // so the user can't tell that the layering is "wrong." I actually tested this with
- // Cyberdog. Lucky!
- //
- // ANOTHER BUG: This method assumes that the caller to ActivateFrontWindows is first
- // doing the DisposeDialog. If DisposeDialog is called after ActivateFrontWindows,
- // we'll still get the same ordering problem. Fortunately, this can be fixed by the
- // part developer.
- // -CSL 7/30/96
-
- ODWindowIterator* iter = kODNULL; ODVolatile(iter);
- WindowPtr bottomFloatingMacWin = kODNULL;
-
- SOM_TRY
-
- // 1. Find bottom floating ODWindow
-
- // Note: It would seem to make sense to traverse the Window Manager (WM) window list
- // and check each window to see if it's a floating ODWindow. Doing this is
- // very expensive because calling AcquireODWindow creates an iterator every time.
- // Instead, we do it the other way around--iterate through the non-ordered ODWindow
- // list and for each floater, find it by inexpensively traversing the WM window list.
- // This routine should be lightweight.
- iter = somSelf->CreateWindowIterator( ev );
- for (ODWindow* currentODWin = iter->First( ev ); iter->IsNotComplete( ev );
- currentODWin = iter->Next( ev ))
- {
- // If it's a floater, find it in the WM List
- if ( currentODWin->IsFloating( ev ))
- {
- // Traverse WM list
- WindowPtr targetMacWin = currentODWin->GetPlatformWindow( ev );
- ODBoolean targetIsDeeper = kODFalse;
- WindowPtr currentMacWin = GetWindowList();
- while ( currentMacWin )
- {
- if ( currentMacWin == bottomFloatingMacWin )
- targetIsDeeper = kODTrue;
-
- if ( currentMacWin == targetMacWin ) // Found it
- {
- if ( targetIsDeeper || bottomFloatingMacWin == kODNULL )
- bottomFloatingMacWin = targetMacWin;
- break;
- }
- currentMacWin = GetNextWindow( currentMacWin );
- WASSERTM( currentMacWin, "Didn't find the ODWindow!" );
- }
- }
- }
-
- // 2. For all non-floating ODWindows on top of the bottom floater call SendBehind,
- // but don't alter the relative order of the non-floaters.
- if ( bottomFloatingMacWin != kODNULL )
- {
- // In this case we must make the outside loop walk the Window Manager list because
- // we need to move misplaced windows back in the correct order. The inside loop
- // is actually embedded in the call to AcquireODWindow. In most cases, there will
- // only be one window that needs to be moved, so the expense here isn't bad.
- WindowPtr sendBehindMacWin = bottomFloatingMacWin;
- WindowPtr currentMacWin = GetWindowList();
- while ( currentMacWin != kODNULL && currentMacWin != bottomFloatingMacWin )
- {
- TempODWindow currentODWin = somSelf->AcquireODWindow( ev, currentMacWin );
- if ( currentODWin != kODNULL && !currentODWin->IsFloating( ev ))
- {
- WindowPtr nextMacWin = GetNextWindow( currentMacWin );
- SendBehind( currentMacWin, sendBehindMacWin );
- sendBehindMacWin = currentMacWin;
- currentMacWin = nextMacWin;
- }
- else
- currentMacWin = GetNextWindow( currentMacWin );
- }
- }
-
- ODDeleteObject( iter );
-
- SOM_CATCH_ALL
-
- if ( iter )
- ODDeleteObject( iter );
-
- SOM_ENDTRY
- }
-